<form role="form" action="" class="frm-operate" method="post">
    <div class="card shadow-none">
        <div class="card-body">
            <input type="hidden" name="row[type]" value="more">
            <div class="form-group row">
                <label for="frm-name" class="col-sm-2 row-form-label"><span class="text-danger">*</span> {:lang("Model name")}</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" id="frm-name" name="row[name]" placeholder="{:lang("Model name")}" data-rule="required">
                </div>
            </div>
            <div class="form-group row">
                <label for="frm-alias" class="col-sm-2 row-form-label">{:lang("Model alias")}</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" id="frm-alias" name="row[alias]" placeholder="{:lang("Model alias")}">
                </div>
            </div>
            <div class="form-group row">
                <label for="frm-tablename" class="col-sm-2 row-form-label"><span class="text-danger">*</span> {:lang("Table Name")}</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" id="frm-tablename" name="row[tablename]" placeholder="{:__('Table names starting with letters do not need to write database table prefixes')}" data-rule="required">
                </div>
            </div>
            <div class="form-group row">
                <label for="frm-diyname" class="col-sm-2 row-form-label">{:lang("Custom URL")}</label>
                <div class="col-sm-8">
                    <input type="text" class="form-control" id="frm-diyname" name="row[diyname]" placeholder="{:__('Aliases for custom URL addresses, only alphanumeric underscores are supported')}">
                </div>
            </div>
            <div class="form-group row">
                <label for="frm-controller" class="col-sm-2 row-form-label">{:lang("Controller")}</label>
                <div class="col-sm-8">
                    {:build_select('row[controller]', $con, 'Archives', ['class'=>"form-control",'id'=>'f-controller'])}
                </div>
            </div>

            <div class="form-group row">
                <label for="frm-remark" class="col-sm-2 row-form-label">{:lang("Remark")}</label>
                <div class="col-sm-8">
                    <textarea class="form-control" id="frm-remark" name="row[remark]" rows="3"></textarea>
                </div>
            </div>

            <div class="form-group row global_search">

            </div>

            <div class="form-group row">
                <label class="col-sm-2 row-form-label">{:lang("Status")}</label>
                <div class="col-sm-8">
                    {:build_radios('row[status]',['normal'=>lang("Normal"),'hidden'=>lang("Hidden")])}
                </div>
            </div>
        </div>
        <div class="card-footer">
            <div class="row justify-content-around">
                <div class="col-sm-8">
                    <button type="submit" class="btn btn-primary btn-submit">{:lang('Submit')}</button>
                    <button type="reset" class="btn btn-default">{:lang('Reset')}</button>
                </div>
            </div>
        </div>
    </div>
</form>

{block:script}
<script>
    require(['admin','form'], function (admin, Form) {
        var controllers = {$controllers|raw};
        Form.api.init();
        $('#f-controller').change(function (e) {
            $('input[name="row[type]"]').val(controllers[$(this).val()]['type']);
            if (controllers[$(this).val()]['is_search']!='-1') {
                $('.global_search').html('<label class="col-sm-2 row-form-label">{:lang("Global search")}</label>\n' +
                    '                <div class="col-sm-8">\n' +
                    '                    {:build_radios(\'row[is_search]\',[\'1\'=>lang("Allow"),\'0\'=>lang("Not allow")])}\n' +
                    '                </div>');
            } else {
                $('.global_search').html('<input type="hidden" name="row[is_search]" value="-1">');
            }
        });
        $('#f-controller').trigger('change');
    })
</script>
{/block:script}

